<%--
  Created by IntelliJ IDEA.
  User: Lemon
  Date: 2020/6/11
  Time: 14:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>首页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <!-- 引入 ECharts 文件 -->
    <script src="${pageContext.request.contextPath}/static/js/echarts.min.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css"  media="all">
</head>
<style>
    body{
        background: white;
    }
    .layui-card-header{
        border-left: 5px solid #009688;
    }
    .layui-container{
        margin-top:20px;
    }
</style>
<body>
<div class="layui-container">
    <div class="layui-row">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header" >客户趋势</div>
                <div class="layui-card-body" >
                    <form class="layui-form" action="" style="margin-top:30px;">
                        <div class="layui-form-item" style="text-align:center;">
                            <div class="layui-inline">
                                <label class="layui-form-label">统计</label>
                                <div class="layui-input-inline" style="width:100px;">
                                    <select name="day" >
                                        <option value="7" selected>7天</option>
                                        <option value="30">30天</option>
                                        <option value="60">60天</option>
                                    </select>
                                </div>
                                <button id="customerButton" class="layui-btn layui-btn-primary" type="button">确定</button>
                            </div>
                        </div>
                    </form>
                    <div id="homePage" style="width:100%;height:500px">
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-col-md12" >
            <div class="layui-card">
                <div class="layui-card-header" >客户来源</div>
                <div class="layui-card-body" >
                    <div id="customerOrigin" style="width:100%;height:500px;"></div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script src="${pageContext.request.contextPath}/static/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript">
    layui.use(['element','jquery','layer','form','laydate','layedit'], function() {
        var $ = layui.jquery
            ,element = layui.element;
        var layer = layui.layer;
        var form = layui.form;
        var laydate = layui.laydate;

        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('homePage'));

        var option = {
            title: {
                text: '客户新增趋势',
            },
            tooltip:{  //鼠标经过显示提示框
                show : true,
                trigger: "axis"
            },
            legend:{  //不同的线的类型
                data: ["客户新增量", "客户损失量"]
            },
            toolbox:{  //工具栏
                show: true,
                feature:{
                    dataView: {readOnly: false},
                    magicType: {type: ['line', 'bar']},  //图形切换
                    restore: {},
                    saveAsImage: {}
                }
            },
            dataZoom: [  //滚动条
                {
                    type: 'slider',
                    show: true,
                    start: 0,
                    end: 100
                }
            ],
            xAxis: {
                name: "时间",
                type: 'category',
                data: ['06-17', '06-18', '06-19', '06-20', '06-21', '06-22', '06-23']
            },
            yAxis: {
                name: "新增/损失 客户量",
                type: 'value',
                max : 8,
                min : 0,
                splitNumber : 4,
            },
            series: [
                {
                    name: '客户新增量',
                    type: 'line',
                    data: [0, 1, 8, 0, 7, 0, 0]
                },
                {
                    name: "客户损失量",
                    type: "line",
                    data: [0, 0, 1, 0, 0, 0, 0]
                }
            ]
        };

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);


        //客户来源
        var myChart = echarts.init(document.getElementById('customerOrigin'));

        var option = {
            title: {
                text: '公司客户来源统计',
                subtext: '东软客户关系管理系统',
                x:'center'
            },
            tooltip:{  //鼠标经过显示提示框
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },
            legend: {
                type: "scroll",
                orient: 'vertical',
                left: 'left',
            },
            series: [
                {
                    name: '客户量',
                    type: 'pie',
                    radius : '55%',
                    center: ['50%', '60%'],
                    data:[
                        {value: 2, name: '不知道从哪来的'},
                        {value: 1, name: '客户介绍'},
                        {value: 3, name: '手工录入'},
                        {value: 22, name: '不清楚'},
                        {value: 3, name: '朋友介绍'},
                        {value: 5, name: '注册会员'},
                        {value: 1, name: '捡到的'}
                    ],
                    itemStyle: {
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        };

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    });
</script>

</html>